package com.kern.academic.vo;

import com.kern.academic.entity.XUser;
import lombok.Data;

/**
 * Created by caoshi at 8:28 2021-07-04
 */
@Data
public class UserVO {


    private String userId;

    private String username;

    private String phone;

    private String email;

    private String roleName;

    private Boolean enable;

    public UserVO() {
    }

    public UserVO(String username, String phone, String email, String roleName, Boolean enable) {
        this.username = username;
        this.phone = phone;
        this.email = email;
        this.roleName = roleName;
        this.enable = enable;
    }

    /**
     *  由 Xuser 转 UserVO
     * @param user
     */
    public void buildByXUser(XUser user) {
        this.setUserId(user.getId());
        this.setUsername(user.getUsername());
        this.setPhone(user.getPhone());
        this.setEmail(user.getEmail());
        this.setEnable(user.getEnable() == 1);
        if (user.getRole() == null) {
            this.setRoleName("");
        } else {
            this.setRoleName(user.getRole().getRoleName());
        }
    }


}
